package thread;

/**
 * 匿名内部类写
 */
public class ThreadDemo3 {
    public static void main(String[] args) {
        //继承后重写
        Thread t1=new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 5; i++) {
                    System.out.println("222");
                }
                int priority=this.getPriority();
                System.out.println("The priority is:"+priority);
                boolean isAlive=this.isAlive();
                boolean isInterrupted=this.isInterrupted();
                boolean isDaemon=this.isDaemon();

                System.out.println("是否存活："+isAlive);
                System.out.println("是否是守护线程："+isDaemon);
                System.out.println("是否被中断："+isInterrupted);
            }
        };
        t1.start();
        //任务与线程解耦
//        Runnable r1=() ->{
//            for (int i = 0; i < 100; i++) {
//                System.out.println("Open the door!!");
//            }
//        };
//        Thread t2=new Thread(r1);
//        t2.start();



    }
}


